import { NextResponse } from 'next/server'
import type { NextRequest } from 'next/server'

export function middleware(request: NextRequest) {

  //放行静态资源文件
  if(request.nextUrl.pathname.startsWith("/_next/static")){
    return 
  }
  //非登录页面都拦截，判断token
  if(!request.nextUrl.pathname.startsWith("/home/login")){
  
    if(request.cookies.get('token')===undefined){
        // 重定向
       return NextResponse.redirect(new URL("/home/login",request.url))
    }
  }
}
 